<template>
  <div>
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'rows'"
      :isSubmitBtn="false"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      columnsRef="partPartOutboundPartSalesNetworkOrderDetail"
      selectionType="single"
    ></FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <div>
        <el-button @click="closeDrawer()">关 闭</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { customerDetail, customerType } from '@/api/part/partOut/partSales/index';
export default {
  name: 'networkOrderDetail',
  mixins: [dictionary],
  props: {
    row: {
      type: Object
    }
  },
  data() {
    return {
      fetchApi: customerDetail, // 调用接口
      fetchParams: { xhrAbort: false }, // 调用数据
      columns: this.createTablelist()
    };
  },
  mounted() {},
  methods: {
    closeDrawer(type) {
      this.$emit('close');
    },
    createTablelist() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
        },

        {
          title: '单位',
          dataIndex: 'UNIT_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '单位',
          dataIndex: 'UNIT_CODE',
          hidden: true
        },
        {
          title: '数量',
          sorter: true,
          dataIndex: 'PART_QUANTITY',
          filter: true,
          filterType: 'number'
        },
        {
          title: '配件销售单价',
          dataIndex: 'PART_SALES_PRICE',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        {
          title: '配件销售金额',
          dataIndex: 'PART_SALES_AMOUNT',
          render: props => {
            props.row.PART_SALES_AMOUNT = this.numFilter((+props.row.PART_SALES_PRICE ? +props.row.PART_SALES_PRICE : 0) * +props.row.PART_QUANTITY);
            return <span>{props.row.PART_SALES_AMOUNT}</span>;
          },
          sorter: true,
          filter: true,
          filterType: 'number'
        }
      ];
    }
  }
};
</script>
